<?php
	$label = '资源列表';
	$rurl= array('/listing/index');
	$htmlOption = array();
	echo CHtml::link($label,$rurl,$htmlOption);
?> &gt;&gt; 
<?php
	$label = Fish::xr(Fish::getRow('artist',$album['artist_id']),'name');
	$rurl= array('listing/artist','id'=>$album['artist_id']);
	$htmlOption = array();
	echo CHtml::link($label,$rurl,$htmlOption);
?>  &gt;&gt; <?php echo $album['name'] ?>
<div class="summary">
	<div style='float:right;'>
		<?php
			$label = '<button class="bt2">创建 '.$album['name'].' 新歌曲</button>';
			$rurl= array('/admin/createSong','aid'=>$album['id']);
			$htmlOption = array();
			echo CHtml::link($label,$rurl,$htmlOption);
		?>
		<?php
			$label = '<button class="bt2">编辑 '.$album['name'].' 专辑</button>';
			$rurl= array('/admin/updateAlbum','id'=>$album['id']);
			$htmlOption = array();
			echo CHtml::link($label,$rurl,$htmlOption);
		?>
		<?php
			$label = '<button class="bt2">连接版本和其他翻译</button>';
			$rurl= array('/presenter/admin/searchTranslation','album_id'=>$album['id']);
			$htmlOption = array();
			echo CHtml::link($label,$rurl,$htmlOption);
		?>
	</div>
	<div class="description">
		<h3 >专辑简介</h3>
		<div >
			<?php if (file_exists(Yii::getPathOfAlias('webroot').'/res/cover/_b'.$album['id'].'.png')): ?>
				<img src="/res/cover/_b<?php echo $album['id'] ?>.png" alt="Cover" title="<?php echo $album['name'] ?>" />
			<?php endif ?>
		</div>
		<div><?php echo $album['content'] ?></div>
		<div>目前收录 <?php echo count($result) ?> 首歌曲</div>
		<div >
			专辑整理 by <?php echo Fish::xr(Fish::getRow('user',$album['user_create']),'name') ?>
			于 <?php echo date('d M Y',strtotime($album['date_create'])); ?>
			<div class='clear'></div>
			曲目整理 by 
			<?php
				foreach ($result as $key => $row)
					$arr[] = Fish::xr(Fish::getRow('user',$row['user_create']),'name');
				$arr = array_unique($arr);
				echo implode($arr,',');
			?>
		</div>
	</div>
	<div class='clear'></div>
	
</div>
<div class='clear' style='height:20px'></div>



<table class="grid-listing">
	<tr >
		<th style='width:24px;'>No.</th>
		<th style='width:48px;'>语言</th>
		<th >曲目</th>
		<th >歌词</th>
		<th >Mp3</th>
		<th >其他版本</th>
		<th >其他翻译</th>
		<th ></th>
	</tr>
	<?php foreach ($result as $song): ?>
	<tr >
		<td ><?php echo $song['track_no'] ?></td>
		<td ><?php echo Yii::app()->params['flag']['lang'][$song['lang']] ?></td>
		<td ><?php echo $song['name'] ?></td>
		<td ><?php
			$label = '&#9731;&#9731;';
			$rurl= array('/listing/lyric','id'=>$song['id']);
			$htmlOption = array('class'=>'colorbox');
			echo CHtml::link($label,$rurl,$htmlOption);
		?></td>
		<td >
			<?php 
			$path = '/res/mp3s/a'.$album['artist_id'].'/b'.$song['album_id'].'/'.$song['track_no'].'.mp3';
			if (file_exists(Yii::getPathOfAlias('webroot').$path)): ?>
			<a href="<?php echo $path ?>" target='_player' >&#9834;&#9835;</a>
			<?php else: ?>
				我没有CD..要帮忙联系我
			<?php endif ?>
		</td>
		<td >
		<?php if (array_key_exists($song['id'],$link1)): ?>
			<?php foreach ($link1[$song['id']] as $songid): ?>
				<div><?php
					$label = $linkinfo[$songid]['album_name'];
					$rurl= array('/listing/album','id'=>$linkinfo[$songid]['album_id']);
					$htmlOption = array();
					echo CHtml::link($label,$rurl,$htmlOption);
				?></div>
			<?php endforeach ?>
		<?php else: ?>
			还没好
		<?php endif ?>
		</td>
		<td >
		<?php if (array_key_exists($song['id'],$link2)): ?>
			<?php foreach ($link2[$song['id']] as $songid): ?>
				<div><?php
					$label = $linkinfo[$songid]['album_name'];
					$rurl= array('/listing/album','id'=>$linkinfo[$songid]['album_id']);
					$htmlOption = array();
					echo CHtml::link($label,$rurl,$htmlOption);
				?></div>
			<?php endforeach ?>
		<?php else: ?>
			还没好
		<?php endif ?>
		</td>
		<td >
			<?php
				$label = '<button class="small bt3">更改</button>';
				$rurl= array('/admin/updateSong','id'=>$song['id']);
				$htmlOption = array('');
				echo CHtml::link($label,$rurl,$htmlOption);
			?>
			<?php
				/*
				# check session chooseOriginal
				if (isset(Yii::app()->session['chooseOriginal'])&&!empty(Yii::app()->session['chooseOriginal'])) {
					# check this is linked
					if ( 
						!(isset($row['belongTo'])) &&
						!(isset($row['belongTo2']))
					) {
						$label = '<button class="bt2">I\'m Translator</button>';
						$rurl= array('/presenter/admin/chooseTranslator','id'=>$row['id']);
						$htmlOption = array();
						echo CHtml::link($label,$rurl,$htmlOption);
						$label = '<button class="bt2">I\'m Same</button>';
						$rurl= array('/presenter/admin/chooseSame','id'=>$row['id']);
						$htmlOption = array();
						echo CHtml::link($label,$rurl,$htmlOption);
					}
				} else {
					
					# check this is linked
					if ( 
						(isset($row['belongTo'])&&!empty($row['belongTo'])) ||
						(isset($row['belongTo2'])&&!empty($row['belongTo2']))
					) {
						$label = '<button class="bt2">Edit Me</button>';
						$rurl= array('/presenter/admin/editLink','id'=>$row['id']);
						$htmlOption = array();
						echo CHtml::link($label,$rurl,$htmlOption);
					} else {
						$label = '<button class="bt2">Use Me</button>';
						$rurl= array('/presenter/admin/chooseOriginal','id'=>$row['id']);
						$htmlOption = array();
						echo CHtml::link($label,$rurl,$htmlOption);
					}
					
				}
				*/
			?>
		</td>
	</tr>
	<?php endforeach ?>
</table>